package com.le.tester.javaThink.fifth.chapter24_ConcurrentProgramming;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.IntStream;

/**
 * createTime：2021/8/18 9:40
 * description：CachedThreadPool2，并发中的变量共享，控制读写的时机才能使用好并发编程
 */
public class CachedThreadPool2 {
    public static void main(String[] args) {
        ExecutorService service = Executors.newCachedThreadPool();
        IntStream.range(0, 10)
                .mapToObj(InterferingTask::new)
                .forEach(service::execute);
        service.shutdown();
    }
}
